﻿@using AntDesigner.NetCore.GameCity;
@model IRoom
@{
    Layout = "~/Views/Shared/_LayoutGameCityRoom.cshtml";
}
@section styles{
    <style>
        .canvasContener {
            height:20%;

        }
        .tools {
            height: 20%;

        }
            .tools button {
                background: linear-gradient(30deg,#f69105,green);
                width: 30px;
                line-height: 24px;
                margin-right: 1rem;
                border-radius: 0.5rem;
                color: yellow;
                border-width: 0;
                height: 75%;
                border-width: 2px;
                border-color: yellow;
             
            }
    </style>
}
<div class="canvasContener">
    <canvas></canvas>
</div>
<div class="canvasContener">
    <canvas id="opponentPayOutPoker"></canvas>
</div>
<div class="canvasContener" >
    <canvas id="payOutPoker"></canvas>
</div>
<div class="canvasContener">
    <canvas id="handPoker"></canvas>
</div>
<div class="tools">
    <button id="payOut">出牌</button>
        <button id="getPoker">要牌</button>
</div>

@section scripts{
    <script src="~/lib/jquery-ant-canvas-poker/jquery.ant.canvas.poker.js" type="text/javascript">
    </script>
    <script>
        var payOutPoker = $("#payOutPoker");
        var handPoker = $("#handPoker");
        var opponentPayOutPoker = $("#opponentPayOutPoker");
        function Poker(color, name) {
            this.CardColor = color;
            this.Name = name;
            this.ComparedValue = null;
        }
        //绘制
        var preOppentPokerPayOut = new Poker();
        function Fresh(gameFace) {
            var myPokerPayOut = null;
            if ((gameFace.myPayOutPoker) != null && gameFace.myPayOutPoker.CardColor.length>0)
            {
                 myPokerPayOut = new Poker(gameFace.myPayOutPoker.CardColor, gameFace.myPayOutPoker.Name);
            }
            if (gameFace.myComparePoker != null && gameFace.myComparePoker.CardColor.length>0)
            {
               myPokerPayOut = new Poker(gameFace.myComparePoker.CardColor, gameFace.myComparePoker.Name);
            }
      
            CleanTable();      //清空界面
            if ((myPokerPayOut) != null&& myPokerPayOut.CardColor.length>0)
            {
                payOutPoker.drawPoker({ pokers: [myPokerPayOut], size: 50, x: payOutPoker.width() / 2 });
            }
            if ((gameFace.myPoker) != null&&gameFace.myPoker.CardColor.length>0)
            {
                var myPokerHand = new Poker(gameFace.myPoker.CardColor, gameFace.myPoker.Name);
                handPoker.drawPoker({ pokers: [myPokerHand], size: 50, x: handPoker.width() / 2 });
            } //刷新我手上的牌
            if ((gameFace.otherPlayersPoker) != null && gameFace.otherPlayersPoker.CardColor.length > 0
                && gameFace.myComparePoker != null && gameFace.myComparePoker.CardColor1.length>0)
            {
                var oppentPokerPayOut = new Poker(gameFace.otherPlayersPoker.CardColor, gameFace.otherPlayersPoker.Name);
                opponentPayOutPoker.drawPoker({ pokers: [oppentPokerPayOut], size: 50, x: opponentPayOutPoker.width() / 2 });
            } //刷新我出的牌
            console.debug("after_GameFace");    //刷新对手出的牌
        }
        canvas = $("canvas");
        ///还原所有画布
        function CleanTable() {
            $.each(canvas, function (i, v) { CleanCanv(v);});
        }
        //出牌比较
        function PlayOutCard() {
            console.debug("befor_PlayOutCard");
            var methodInfo = new MethodInfo("PlayerPlayOutOnePoker");
            var mySeat = InvokeSeverMethod(methodInfo);
            console.debug("after_PlayOutCard");
        }
        //获得一张牌
        function GetNewPoker() {
            console.debug("befor_GetNewPoker");
            CleanCanv($("#opponentPayOutPoker")[0]);
            var methodInfo = new MethodInfo("PlayerGetOnePoker");
            var poker = InvokeSeverMethod(methodInfo);
            console.debug("after_GetNewPker");
        }
        $("#payOut").on("click", PlayOutCard);
        $("#getPoker").on("click", GetNewPoker);
        //js控制布局
        function C_GameStopgoon() {
            alert("继续游戏");
        }
        $(function () {
            $(window).resize(function () {
                _gameFace.Fresh();
            });
            Fresh(gameFace);
        });
    </script>
}
